"""
给两个字符串s和t 判断s是不是t打乱后重新组合而成的
S = anagram t = nagaram return True
s = tat t = cat return false
"""
# 将两个列表分别排序 看是不是相等
def sort1(s:str,t:str):
    s = sorted(s)
    t = sorted(t)
    if s == t:
        return True
    else:
        return False
res = sort1("anagram","nagaram")
print(res)
res = sort1("tat","cat")
print(res)

# 遍历一个
def sort2(s:str,t:str):
    s_list = list(s)
    t_list = list(t)
    for i in s_list:
        if i not in t_list:
            return False
        t_list.remove(i)
    return True
res = sort2("anagram","nagaram")
print(res)
res = sort2("tat","cat")
print(res)